/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package QASystem;

import com.sun.security.auth.login.ConfigFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

/**
 *
 * @author Raito
 */
public class Config {

    private static final String configFile = "Configuration/config.xml";

    /**
     * 
     * @return List<String> all of predefined syntax files
     * @throws ParserConfigurationException
     * @throws SAXException
     * @throws IOException 
     */
    public static List<String> getAllSyntaxFiles() throws ParserConfigurationException, SAXException, IOException {
        String nodeValue = "";
        List<String> config = new ArrayList<String>();
        File file = new File(configFile);
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
        Document xmlDocument = documentBuilder.parse(file);
        xmlDocument.getDocumentElement().normalize();
        NodeList nodeList = xmlDocument.getElementsByTagName("item");
        for (int s = 0; s < nodeList.getLength(); s++) {
            Node currentNode = nodeList.item(s);
            if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
                nodeValue = currentNode.getChildNodes().item(0).getNodeValue();
                config.add(nodeValue);
            }
        }
        return config;
    }

    
}
